/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 */

package com.huawei.radar.demo;

import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.dris.v1.DrisClient;
import com.huaweicloud.sdk.dris.v1.model.BatchShowRadarsRequest;
import com.huaweicloud.sdk.dris.v1.model.BatchShowRadarsResponse;
import com.huaweicloud.sdk.dris.v1.region.DrisRegion;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Radar管理示例
 *
 * @author p00631112
 * @since 2023-01-05
 */
public class RadarSolutionDemo {
    private static final Logger logger = LoggerFactory.getLogger(RadarSolutionDemo.class);

    public static void main(String[] args) {
        String ak = "<YOUR AK>";
        String sk = "<YOUR SK>";

        // 创建DrisClient实例
        ICredential auth = new BasicCredentials()
            .withAk(ak)
            .withSk(sk);
        DrisClient client = DrisClient.newBuilder()
            .withCredential(auth)
            .withRegion(DrisRegion.valueOf("cn-north-4"))
            .build();

        BatchShowRadarsRequest request = new BatchShowRadarsRequest();
        try {
            BatchShowRadarsResponse response = client.batchShowRadars(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            logger.error("ConnectionException", e);
        } catch (RequestTimeoutException e) {
            logger.error("RequestTimeoutException", e);
        } catch (ServiceResponseException e) {
            logger.error("ServiceResponseException", e);
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}
